#pragma once

/// <summary>
/// InputClass: Responsible for updating mouse and keyboard input
/// <summary>

/**	
  * Author: Michael Leviston
  * Created: 14/05/13
  * Last Modified: 29/06/13
  * Version: v1.0
  */

#define DIRECTINPUT_VERSION 0x0800
#pragma comment(lib, "dinput8.lib")
#pragma comment(lib, "dxguid.lib")

// Includes
#include <dinput.h>

// Class Definition
class InputClass
{
public:

//==============================
// Constructors / Destructors
//==============================

	/// Default Constructor
	InputClass();

	/// Copy Constructor
	InputClass(const InputClass&);

	/// Default Destructor
	~InputClass();

//==============================
// Initialisation
//==============================

  /**
	* Initialise the Input Class instance
	*
    * Initialiser that configures the input class to the application window
	* @param application instance
	* @param main application window
	* @param screen width
	* @param screen height
	*/
	bool Initialise(HINSTANCE hInstance, HWND hwnd, int screenWidth, int screenHeight);

//==============================
// Shutdown Method
//==============================

	/// Default Shutdown Method
	void Shutdown();

//==============================
// Update Method
//==============================

	/// Update Method called every frame
	bool Update();

//==============================
// Get State Methods
//==============================

  /**
	* Is Key Pressed
	*
    * Returns if a specific key is pressed
	* @param int between 0-255 representing the key
	* @return bool if key is pressed or not
	*/
	bool IsKeyPressed(int);

  /**
	* Is Button Pressed
	*
    * Returns if a specific mouse button is pressed
	* @param int representing the mouse button
	* @return bool if button is pressed or not
	*/
	bool IsButtonPressed(int);

  /**
	* Get Mouse Location
	*
    * Returns the x y coordinates of the mouse cursor
	* @param int& to store the x value
	* @param int& to store the y value
	*/
	void GetMouseLocation(int&, int&);

//==============================
// Read Device Methods
//==============================

private:

	/// ReadKeyboard - Updates which keys are pressed
	bool ReadKeyboard();

	/// ReadMouse - Updates which mouse buttons are pressed
	bool ReadMouse();

	/// ProcessInput - Updates the mouse cursor location
	void ProcessInput();

private:
	IDirectInput8* m_directInput;			///< Pointer to direct input device
	IDirectInputDevice8* m_keyboard;		///< Pointer to direct input keyboard
	IDirectInputDevice8* m_mouse;			///< Pointer to direct input mouse

	unsigned char m_keyboardState[256];		///< Array storing keyboard key presses
	DIMOUSESTATE m_mouseState;				///< Array storing mouse button presses

	int m_screenWidth;						///< Int storing Screen Width
	int m_screenHeight;						///< Int storing Screen Height
	int m_mouseX;							///< Int storing current mouse X position
	int	m_mouseY;							///< Int storing current mouse Y position
};